package com.hgx.flink.scala.demo

import org.apache.flink.api.scala._
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment

object StreamWordCount2 {
  def main(args: Array[String]): Unit = {

    //获取运行环境
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    //链接socket获取输入数据
    val inputDataStream = env.socketTextStream("106.14.217.80", 8500)

    val resultStream = inputDataStream.flatMap(_.split(" "))
      .map((_, 1))
      .keyBy(0)
      .sum(1);


    resultStream.print();

    env.execute()
  }
}
